package be.novelfaces.showcase.webdriver.festassert;

import org.fest.assertions.Assertions;
import org.fest.assertions.GenericAssert;

import be.novelfaces.component.webdriver.SourcePanel;

public class SourcePanelAssert extends
		GenericAssert<SourcePanelAssert, SourcePanel> {

	public SourcePanelAssert(SourcePanel actual) {
		super(SourcePanelAssert.class, actual);
	}

	public static SourcePanelAssert assertThat(SourcePanel actual) {
		return new SourcePanelAssert(actual);
	}

	public SourcePanelAssert hasHeader(String header) {
		isNotNull();
		String errorMessage = String.format(
				"Expected header to be <%s> but was <%s>", header,
				actual.getHeader());
		Assertions.assertThat(actual.getHeader())
				.overridingErrorMessage(errorMessage).isEqualTo(header);
		return this;
	}

	public SourcePanelAssert containsContent(String contentToContain) {
		isNotNull();
		String errorMessage = String.format("Expected to contain <%s> in content of panel",
				contentToContain);
		Assertions.assertThat(actual.containsContent(contentToContain))
				.overridingErrorMessage(errorMessage).isTrue();
		return this;
	}

	public SourcePanelAssert isRendered() {
		isNotNull();
		Assertions.assertThat(actual.isRendered()).isTrue();
		return this;
	}
	
	public SourcePanelAssert isCollapsed(boolean collapsed) {
		isNotNull();
		Assertions.assertThat(actual.isCollapsed()).isEqualTo(collapsed);
		return this;
	}
	
}
